#ifndef MOVINGOBJECT_H
#define MOVINGOBJECT_H
#include <d3dx9.h>
#include <math.h>
#include "Steering.h"
#include "Vector3D.h"

#define PI 3.141

class Steering;

class MovingObject
{
private:
	Vector3D v3Position;	//the current position of the object
	float fSpeed;			//the maximum speed (scalar) that the object can go
	float fAngle;			//the angle representing the object's current heading in radians
	float fDesiredAngle;	//the angle representing the way the object should be heading

	//strenalis needs to make more than one velocity, one for each steering behaviors
	//then all of them can be combined to have the net force
	//strenalis also has to make flags to determine which steering behavior is actually on. ie SeekOn();


	Vector3D v3Velocity;	//velocity as a vector; this value is determined by the various steering functions and should only be set using those functions
	Vector3D v3Accel;		//acceleration as a vector; this value will be used in some steering functions
	Vector3D v3Target;		//vector representing the object's target (for example, it may be fleeing away, or seeking towards it)
	Steering mySteering;	//pointer to this object's steering behaviors

public:
	//two constructors, one takes no parameters, the other takes two
	MovingObject(): mySteering(this) {v3Position.setCoord(0, 0, 0); v3Velocity = v3Target = v3Accel = v3Position; fSpeed = 5; fAngle = 0;
										D3DXMatrixTranslation(&d3dPosition, v3Position.getX(), v3Position.getY(), v3Position.getZ());
										D3DXMatrixTranslation(&d3dTarget, v3Target.getX(), v3Target.getY(), v3Target.getZ());}

	D3DXMATRIX d3dPosition; //the current position of the object in a format that DirectX can use
	D3DXMATRIX d3dTarget;	//the target position of the object in a format that DirectX can use
	D3DXMATRIX d3dAngle;	//the angle the object is facing in a format that DirectX can use

	//each set function is overloaded so user can either pass a vector, or an x, y, z coordinate
	void setPosition(Vector3D pos);										
	void setPosition(float x, float y, float z);
	void setSpeed(float v) { fSpeed = v; }
	void setVelocity(Vector3D vel) { v3Velocity = vel; }
	void setVelocity(float x, float y, float z) { v3Velocity.setCoord(x, y, z); }
	void setAccel(Vector3D a) {v3Accel = a; }
	void setAccel(float x, float y, float z) {v3Accel.setCoord(x, y, z); }
	void setTarget(Vector3D tar);
	void setTarget(float x, float y, float z);
	void setAngle(float theta);
	void setDesiredAngle(float theta) { fDesiredAngle = theta; }

	//get functions
	Vector3D getPosition() { return v3Position; }
	float getSpeed() { return fSpeed; }
	Vector3D getVelocity() { return v3Velocity; }
	Vector3D getAccel() { return v3Accel; }
	Vector3D getTarget() { return v3Target; }
	float getAngle() { return fAngle; }
	float getDesiredAngle() { return fDesiredAngle; }

	void Update(float dt);
	void Calculate();
	bool isAtTarget();
};

#endif